package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.acticle.domain.DestinationTheme;
import cn.wolfcode.luowowo.acticle.domain.DestinationThemeCatalog;
import cn.wolfcode.luowowo.acticle.service.IDestinationThemeService;
import cn.wolfcode.luowowo.article.mapper.DestinationThemeCatalogMapper;
import cn.wolfcode.luowowo.article.mapper.DestinationThemeMapper;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

@Service
public class DestinationThemeServiceImpl implements IDestinationThemeService {

    @Autowired
    private DestinationThemeCatalogMapper destinationThemeCatalogMapper;
    @Autowired
    private DestinationThemeMapper destinationThemeMapper;

    @Override
    public List<DestinationTheme> getDestinationThemeById(Long id) {
        List<DestinationTheme> list = new ArrayList<>();
        DestinationThemeCatalog destinationThemeCatalog = destinationThemeCatalogMapper.selectByPrimaryKey(id);
        Long[] ids = destinationThemeCatalog.getRefIds();

        for (Long tid : ids) {
            DestinationTheme theme = destinationThemeMapper.selectByPrimaryKey(tid);
            list.add(theme);
        }

        return list;
    }
}
